#include "led.h"
#include "stm32f1xx.h"
#include "FreeRTOS.h"
#include "task.h"
volatile int i = 0x30313233;
 
void led_delay()
{
	// for (i = 6; i < 100000; i++)
	// {
	// 	asm("NOP");
	// }
 	// HAL_Delay(500);
	vTaskDelay(500);

}
void led_init()
{
	// PB2 PC13
	__HAL_RCC_GPIOC_CLK_ENABLE();
	//__HAL_RCC_GPIOB_CLK_ENABLE();
	GPIOC->CRH &= ~(0XF0 << 16); // CLEAR CHR CNF13 MODE13
	GPIOC->CRH |= 0x10 << 16;	 // 推挽输出 PC13

	GPIOC->BSRR = 1 << 13; // set pc13

	GPIOC->BSRR = 1 << 13 << 16; // reset pc13

	// GPIOB->CRL &= ~0X0F00;
	// GPIOB->CRL |= 0X0100;

	// GPIOB->BSRR = 1 << 2; // set pB2

	// GPIOB->BSRR = 1 << 2 << 16; // reset pB2
}

void led_flash_loop()
{
	led_init();
	while (1)
	{
		GPIOC->BSRR = 1 << 13 << 16; // reset pc13
		led_delay();
		GPIOC->BSRR = 1 << 13; // set pc13
		led_delay();
	}
}
